package com.bnz.web.listener;

import javax.servlet.annotation.WebListener;
import javax.servlet.http.HttpSessionAttributeListener;
import javax.servlet.http.HttpSessionBindingEvent;
import javax.servlet.http.HttpSessionEvent;
import javax.servlet.http.HttpSessionListener;


@WebListener
public class MySessionListener implements HttpSessionListener, HttpSessionAttributeListener {
	//下面两个方法是session对象的监控
	@Override
	public void sessionCreated(HttpSessionEvent httpSessionEvent) {
		System.out.println("MySessionListener---》sessionCreated");
	}

	@Override
	public void sessionDestroyed(HttpSessionEvent httpSessionEvent) {
		System.out.println("MySessionListener---》sessionCreated");
	}
	//下面三个方法是session中的属性值改变时的监控
	@Override
	public void attributeAdded(HttpSessionBindingEvent httpSessionBindingEvent) {
		System.out.println("MySessionListener---》attributeAdded");
	}

	@Override
	public void attributeRemoved(HttpSessionBindingEvent httpSessionBindingEvent) {
		System.out.println("MySessionListener---》attributeRemoved");
	}

	@Override
	public void attributeReplaced(HttpSessionBindingEvent httpSessionBindingEvent) {
		System.out.println("MySessionListener---》attributeReplaced");
	}


}
